$(function () {
    vm.querySellerInfo();
    if(window.parent.vm.guide && window.parent.vm.guide.indexGuide === 0){
        var ij = new introJs();
        ij.setOptions({
            nextLabel: '下一步',
            prevLabel: '上一步',
            skipLabel: '跳过',
            doneLabel: '完成',
            showBullets: false,
            showProgress: false,
        }).start();
        ij.onexit(function() {
            window.parent.vm.guide.indexGuide = 1;
        });
    }

})

var vm = new Vue({
    el:'#rrapp',
    data:{
        /* 子公司分页参数 */
        subSellerPage:{
            currPage:1, // 当前页
            pageSize:8, // 分页数
            totalCount:0, // 总条数
            tableData:[], //数据列
        },
        sellerInfoVo:{
            sellerName: '',
            url: 'https://ziyunoss.oss-cn-hangzhou.aliyuncs.com/erpTest/test/1538299323397.jpg',
            doorheadName: '',
            name:'',
            sellerMobile:'',
            address: '',
            waitPayNum: 10,
            payedNum: 12,
            sendNum: 23,
            finishNum: 36,
            waitWithdraw: 8600,
            withdrawing: 6923,
            alreadyWithdraw: 98745,
            goodsNum: 100,
            saleGoodsNum: 62,
            offGoodsNum: 38,

            yesterdayPayed: 0,          // 前一天，支付金额
            weekPayed: 0,               // 当前周，支付总金额
            yesterdayVisitors: 0,       // 前一天，访客数
            weekVisitors: 0,            // 当前周，访客总数
            yesterdayBuyers: 0,         // 前一天，支付买家数
            weekBuyers: 0,              // 当前周，支付买家总数
            yesterdayView: 0,           // 前一天，浏览量
            weekView: 0,                // 当前周，浏览量总数
            yesterdaStoreOrderNum: 0,   // 前一天，门店订单
            weekStoreOrderNum: 0,       // 当前周，门店订单总数
            totalMember: 0,             // 全部客户
            ziyunMember: 0,             // 下单注册
            rePurchaseRate: 0,          // 复购率
        },
        chartData:{
            salesList: {
                columns: ['日期', '销量', ],
                rows: []
            },
            tradeData:{
                chartSettings: {
                    axisSite: { right: ['订单数','客户数'] },
                    yAxisType: ['KMB', ''],
                    yAxisName: ['金额', '数量']
                },
                tradeList:{
                    columns: ['日期', '营业额', '订单数', '客户数'],
                    rows: []
                }
            },
            customChartData: {
                columns: ['类型', '客户数'],
                rows: []
            }
        },

    },
    mounted: function () {
        //this.initIntroJs();
    },
    methods: {

        initIntroJs: function () {

        },
        querySellerInfo: function () {
            var self = this;
            $.ajax({
                type: "GET",
                url: baseURL + "supp/sellerinfo/querySellerInfo",
                contentType: "application/json",
                data: null,
                success: function(r){
                    console.log(r);
                    self.sellerInfoVo = r.data.sellerInfoVo;
                    for(var i=0; i<r.data.salesList.length; i++){
                        var list = {
                            '日期': r.data.salesList[i].date,
                            '销量': r.data.salesList[i].sales
                        }
                        var tradeList = {
                            '日期': r.data.salesList[i].date,
                            '营业额': r.data.salesList[i].sales,
                            '订单数': r.data.salesList[i].orderNum,
                            '客户数': r.data.salesList[i].customerNum
                        }

                        self.chartData.salesList.rows.push(list)
                        self.chartData.tradeData.tradeList.rows.push(tradeList)
                    }
                    console.log(self.chartData.customChartData)
                    self.chartData.customChartData.rows = [
                        { '类型': '新客户', '客户数': r.data.custom.newCustom},
                        { '类型': '老客户', '客户数': r.data.custom.oldCustom}
                    ]
                    jQuery('#qrcode').qrcode({
                        width: 200,
                        height: 200,
                        text: 'https://www.11ziyun.com/wap/merchant-info/'+vm.sellerInfoVo.sellerId,
                    });
                }
            });
        },
        skipPage: function (data) {
            window.parent.vm.zyRouter(data);
        }
    }
});